package com.fosdata.dpm.config;


import com.fosdata.dpm.interceptor.SqlStatementInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by yhsh on 2020/7/12 9:41
 * version 2.0
 * 方法说明 配置执行sql的 console 跟踪打印
 */
@Configuration
@MapperScan({"com.fosdata.dpm.services.mapper"})
public class MybatisConfig {

    /**
     * 配置 sql打印拦截器
     * application.yml中 cloud.showsql: true 时生效
     * @return SqlStatementInterceptor
     */
    @Bean
    @ConditionalOnProperty(name = "cloud.showsql", havingValue = "true")
    SqlStatementInterceptor sqlStatementInterceptor() {
        return new SqlStatementInterceptor();
    }

}
